<?php

include './includes.php';


$user = $_SESSION['user'];

if (isset($_SESSION['user']))
{
    $user = $_SESSION['user'];
    if ($user->getAdmin())
    {
        $noticia = postQuery::create()->findPk($_POST['id']);
        
        $noticia->setTitulo($_POST['titulo']);

        $noticia->setTexto($_POST['resumen'] . '[lm]' . $_POST['texto']);

        $sub = subforoQuery::create()->findPk($_POST['subforo']);

        $noticia->setforeign_subforo($sub);

        if (isset($_POST['imagen']))
        {
            $noticia->setforeign_imagen(imagenesQuery::create()->findPk($_POST['imagen']));
        }
        
        $noticia->save();
    }
}

$host3 = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'index.php';
header("Location: http://" . $host3 . $uri . "/" . $extra);
die();
?>
